/*******************************************************************************
 * Copyright (c) 2008, 2009 Tapestry IDE Developers
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Tapestry IDE Developers - initial API and implementation
 *******************************************************************************/
package com.googlecode.tapestry.ide.internal.core;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;

import com.googlecode.tapestry.ide.TapestryPlugin;

/**
 * The Class LogUtils.
 */
public class LogUtils {

	/**
	 * Log.
	 * 
	 * @param message
	 *            the message
	 * @param exception
	 *            the exception
	 */
	public static void log(String message, Throwable exception) {
		IStatus status = createErrorStatus(message, exception);
		TapestryPlugin.getDefault().getLog().log(status);
	}

	/**
	 * Log.
	 * 
	 * @param exception
	 *            the exception
	 */
	public static void log(Throwable exception) {
		TapestryPlugin.getDefault().getLog().log(
				createErrorStatus("Internal Error", exception));
	}

	/**
	 * Creates the error status.
	 * 
	 * @param message
	 *            the message
	 * @param exception
	 *            the exception
	 * 
	 * @return the i status
	 */
	public static IStatus createErrorStatus(String message, Throwable exception) {
		if (message == null) {
			message = "";
		}
		return new Status(IStatus.ERROR, TapestryPlugin.PLUGIN_ID, 0, message,
				exception);
	}

}
